<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    span {
        border-bottom: 1px solid black;
        width: 100px;
        display: inline-block;
        text-align: center;
    }

    input {
        outline: 0;
        border: 0;
        border-bottom: 1px solid black;
        width: 100px;
        font-size: 16px;
        text-align: center;
    }
</style>
<body>
    <div id="root">
        <fieldset>
            <legend>自我介绍</legend>
            <p v-for="(v,k,i) in user">
                <label for="">{{k}}</label>
                :
                <input  type="text" v-model="val" ref="ipt" @blur="escFn(k)" v-if="isEdit&&i===selected">
                <span @dblclick="editFn(v,i)" v-else>{{v}}</span>
            </p>
        </fieldset>
    </div>
</body>
</html>
<script src="http://unpkg.zhimg.com/vue@2"></script>
    <script>
    const vm = new Vue({
     el: "#root",
     data: {
        user: {
            "姓名": "zlc",
            "年龄": 18,
            "爱好": "摸鱼", 
            "身高": "180cm"
        },
        val: "摸鱼",
        isEdit: false,
        selected:""
    },
    methods: {
        editFn(v, i) {
            this.isEdit = true;
            this.selected = i;
            this.val = v;
            this.$nextTick(() => {
                console.log(this.$refs.ipt[0].focus());
            })
        },
        escFn(k) { 
            //退出编辑状态
            this.isEdit = false;
            console.log(k);
            this.user[k] = this.val
        }
     }
})
</script>